using Net.Adapter;
using System.Reflection;
using System.Collections.Generic;

namespace Net.Share
{
    public class MemberData
    {
        public MemberInfo member;
        public Rpc rpc;
        public SyncVarInfo syncVar;
        public RpcMethodPtr ptr;

        public override string ToString()
        {
            return $"{member}";
        }
    }

    public class MemberDataList
    {
        public List<MemberData> members = new();
    }

    public struct RPCMethodPtr : IRpcMethod
    {
        public byte cmd { get; set; }
        public object target { get; set; }
        public MethodInfo method { get; set; }
        public RpcMethodPtr ptr;

        public RPCMethodPtr(object target, MethodInfo method, byte cmd, RpcMethodPtr ptr) : this()
        {
            this.target = target;
            this.cmd = cmd;
            this.ptr = ptr;
            this.method = method;
        }

        public void Invoke()
        {
            ptr.Invoke(target, null);
        }

        public void Invoke(params object[] pars)
        {
            ptr.Invoke(target, pars);
        }

        public override string ToString()
        {
            return $"{method}";
        }
    }
}